package cn.yh.test;

import cn.yh.dao.IBoardDao;
import cn.yh.entity.Board;
import cn.yh.utils.SqlsessionFactoryUtil;
import org.apache.ibatis.session.SqlSession;
import org.junit.Test;

import java.util.List;

public class Demo1 {
    SqlSession se= SqlsessionFactoryUtil.getSession();
    IBoardDao ibd=se.getMapper(IBoardDao.class);
    @Test
    public void test(){
        Board o=new Board();
        String key="日";
        List<Board> list=ibd.keyGetAll(key+"%");
        for (Board b:list) {
            System.out.println(b.getId()+"  :  "+b.getTitle());
        }
    }
    @Test
    public void test1(){
        Board b=new Board();
        b.setTitle("日本男子篮球队在NBA中打球被日本人民骂道打球像蔡徐坤");
        int a=ibd.addBoard(b);
        se.commit();

    }
    @Test
    public void test2(){
        Board b=new Board();
        b.setId(20);
        b.setTitle("日本男子篮球队打球像蔡徐坤");
        ibd.updBoard(b);
        se.commit();

    }
    @Test
    public void test3(){
        ibd.delBoard(20);
        se.commit();
    }

}
